<template>
	<view class="content">
		<view class="play-content-block">
			<video :src="current.videoUrl" class="video" enable-play-gesture="true" :enable-play-gesture="true"
				auto-pause-if-navigate="true" auto-pause-if-open-native="true" show-center-play-btn="true"
				show-fullscreen-btn="true" show-play-btn="true" :title="current.title" custom-cache="false"></video>
		</view>
		<view class="title">醉美肃州欢迎您</view>
		<view class="list-block">
			<view @click="changeVideo(item)" v-for="item in list" :key="item.id" class="list-item">
				<image :src="item.coverUrl" mode="aspectFill" class="photo"></image>
				<view class="info-block">
					<view class="name">{{item.title}}</view>
					<view class="play-amount-block">
						<view class="play-amount">播放量：{{item.counts}}</view>
						<view class="duration">时长：{{item.duration}}</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		postVideoList
	} from '@/api/video_appreciation.js';
	export default {
		data() {
			return {
				list: [],
				current: null,
			}
		},
		onLoad() {

		},
		methods: {
			changeVideo(item) {
				this.current = item;
			},
			findList() {
				postVideoList({
					page: 1,
					limit: 20
				}).then((res) => {
					if (res.code == 1) {
						if (res.data != null) {
							console.log(res)
							this.list = res.data;
							this.current = res.data[0]
						}
					} else {
						console.log(res)
					}
				}).catch((res) => {
					console.log(res)
				})
			}
		},
		onShow() {
			this.findList();
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		display: flex;
		flex-direction: column;

		.play-content-block {
			width: 100%;

			.video {
				width: 100%;
				height: 490rpx;
			}
		}

		.title {
			padding: 20rpx 30rpx;
			line-height: 1.6;
			border-bottom: 1px solid #efefef;
		}

		.list-block {
			padding: 0 30rpx;
			display: flex;
			flex-direction: column;
			height: calc(100vh - 582rpx);
			overflow-y: scroll;

			.list-item {
				border-bottom: 1px solid #efefef;
				padding: 30rpx 0;
				display: flex;
				flex-direction: row;

				.photo {
					width: 220rpx;
					height: 180rpx;
					border-radius: 10rpx;
					margin-right: 20rpx;
				}

				.info-block {
					width: calc(100% - 240rpx);
					display: flex;
					flex-direction: column;

					.name {
						flex-grow: 1;
						display: -webkit-box;
						-webkit-box-orient: vertical;
						-webkit-line-clamp: 3;
						overflow: hidden;
					}

					.play-amount-block {
						display: flex;
						flex-direction: row;
						align-items: center;
						font-size: 24rpx;
						padding: 10rpx 0;
						flex-grow: 0;

						.play-amount {
							flex-grow: 1;
							color: $color-regular-text;
						}

						.duration {
							flex-grow: 0;
							color: $color-regular-text;
						}
					}
				}
			}
		}
	}
</style>
